import request from '@/utils/request'
import type { PageResponse } from '@/types/common'
import type { Contact } from '@/types/customer'

export function getContacts(params: {
  page?: number
  size?: number
  customerId?: string | number
}) {
  return request.get<PageResponse<Contact>>('/api/contacts', { params })
}

export function getContact(id: number) {
  return request.get<Contact>(`/api/contacts/${id}`)
}

export function createContact(data: Partial<Contact>) {
  return request.post<Contact>('/api/contacts', data)
}

export function updateContact(id: number, data: Partial<Contact>) {
  return request.put<Contact>(`/api/contacts/${id}`, data)
}

export function deleteContact(id: number) {
  return request.delete(`/api/contacts/${id}`)
}
